Technical Q&A QA1142
Preventing crashes when using multiple disabled but editable NSComboBoxes


Q: In Mac OS X 10.1.x, my Cocoa app crashes if I have more than one disabled but editable NSComboBox in a view and I click on one of them. How can I prevent this?

A: This is a bug that should be fixed in the next major release of Mac OS X. The workaround is fairly straightforward - use a subclass of NSComboBox that overrides -acceptsFirstResponder like Listing 1 demonstrates.



 @implementation MyComboBox
- (BOOL) acceptsFirstResponder {
       if ([self isEnabled] || NSAppKitVersionNumber>=636)
       return [super acceptsFirstResponder];
       else
    return NO;
}
@end

Listing 1. fixing the NSComboBox bug




[Jun 03 2002]


Developer Documentation | Technical Notes | Development Kits | Sample Code